<template>
  <div>
    <!-- 这里放置电子发票分析检测的组件内容 -->
    <h2>查看已录入数据</h2>
    <el-upload
      class="upload-demo"
      action="https://jsonplaceholder.typicode.com/posts/"
      :on-preview="handlePreview"
      :on-remove="handleRemove"
      :before-upload="beforeUpload"
      :file-list="fileList"
      accept=".pdf"
      :auto-upload="false">
    </el-upload>
    <iframe v-if="pdfUrl" :src="pdfUrl" width="100%" height="600px"></iframe>
  </div>
</template>

<script>
export default {
  name: 'ElectronicInvoiceAnalysis',
  data() {
    return {
      fileList: [],
      pdfUrl: ''
    };
  },
  methods: {
    handleRemove(file, fileList) {
      console.log(file, fileList);
    },
    handlePreview(file) {
      console.log(file);
    },
    beforeUpload(file) {
      const isPDF = file.type === 'application/pdf';
      if (!isPDF) {
        this.$message.error('只能上传PDF文件!');
      }
      return isPDF;
    },
    submitUpload() {
      this.$refs.upload.submit();
    }
  }
}
</script>

<style scoped>
/* 这里放置电子发票分析检测的组件样式 */
</style>